# -*- coding: utf-8 -*-
from django.contrib import admin
from TestModel.models import Test, Contact, Tag

# Register your models here.
# admin.site.register(Test)
# admin.site.register([Test, Contact, Tag])

# 自定义表单
class TagInline(admin.TabularInline):
    model = Tag

class ContactAdmin(admin.ModelAdmin):
    # exg_1 start
    # fields = ('name', 'email')
    # exg_1 end
    # exg_2 start
    # fieldsets = (
    #     ['Main', {
    #         'fields': ('name', 'email'),
    #     }],
    #     ['Advance', {
    #         'classes': ('collapse',),  # CSS
    #         'fields': ('age',),
    #     }]
    # )
    # exg_2 end
    # exg_3 start
    list_display = ('name', 'age', 'email')  # list
    search_fields = ('name',)
    inlines = [TagInline]  # Inline
    fieldsets = (
        ['Main', {
            'fields': ('name', 'email'),
        }],
        ['Advance', {
            'classes': ('collapse',),
            'fields': ('age',),
        }]
    )
    # exg_3 end

admin.site.register(Contact, ContactAdmin)
admin.site.register([Test, Tag])